package com.lhkj.ct.meta.modules.gauge.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.lhkj.ct.base.enums.DeleteStatus;
import com.lhkj.ct.meta.modules.common.enums.RiskLevel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 预警设置
 * </p>
 *
 * @author jobob
 * @since 2023-10-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="TblScaleWarnSetting对象", description="预警设置")
public class TblScaleWarnSetting implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "预警设置id")
    private String id;

    @ApiModelProperty(value = "维度id")
    private String dimId;

    @ApiModelProperty(value = "预警名称")
    private String warnName;

    @ApiModelProperty(value = "预警级别", notes = "0.暂无 1.较低 2.中等 3.较高 4.极高")
    private RiskLevel warnLevel;

    @ApiModelProperty(value = "最小年龄")
    private Integer minAge;

    @ApiModelProperty(value = "最大年龄")
    private Integer maxAge;

    @ApiModelProperty(value = "性别")
    private String suitSex;

    @ApiModelProperty(value = "最小分值")
    private BigDecimal minScore;

    @ApiModelProperty(value = "最小分值运算符")
    private String minOperator;

    @ApiModelProperty(value = "最大分值")
    private BigDecimal maxScore;

    @ApiModelProperty(value = "最大分值运算符")
    private String maxOperator;

    @TableField(fill = FieldFill.INSERT)
    @TableLogic
    @ApiModelProperty(value = "删除状态 0.已删除 1.未删除")
    private DeleteStatus delFlag;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    public String yjAgeExp() {
        String exp = "";
        if (null != minAge) {
            exp += minAge + "<=NL";
        }
        if (null != maxAge) {
            if (StringUtils.isNotBlank(exp)) {
                exp += "&&NL<=" + maxAge;
            } else {
                exp += "NL<=" + maxAge;
            }
        }
        return exp;
    }

    public String yjScoreExp() {
        String exp = "";
        if (null != minScore) {
            exp += String.valueOf(minScore) + minOperator + "Score";
        }
        if (null != maxScore) {
            if (StringUtils.isNotBlank(exp)) {
                exp += "&&Score"+maxOperator + maxScore;
            } else {
                exp += "Score" + maxOperator + maxScore;
            }
        }
        return exp;
    }
}
